package com.ruoyi.web.controller.video;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.video.VsDramasVideo;
import com.ruoyi.system.service.video.IVsDramasVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
 * This file is part of 南阳迈特网络科技有限公司.
 * @company  南阳迈特网络科技有限公司
 * @link     https://www.nymaite.com
 * @document https://product.nymaite.cn
 * @contact  service@nymaite.com
 * @author nymaite
 */
/**
 * 短剧Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@Api(tags = "短剧视频")
@RestController
@RequestMapping("/video/video")
public class VsDramasVideoController extends BaseController
{
    @Autowired
    private IVsDramasVideoService vsDramasVideoService;

    /**
     * 查询短剧列表
     */
    @ApiOperation("查询短剧列表")
    @CrossOrigin(origins = "*")
    @GetMapping("/list")
    public TableDataInfo list(VsDramasVideo vsDramasVideo, HttpServletRequest request)
    {
        startPage();
        if (!StringUtils.isEmpty(request.getHeader("Lang-Id"))) {
            Long integer = Long.valueOf(request.getHeader("Lang-Id"));
            vsDramasVideo.setLangId(integer);
        }
        List<VsDramasVideo> list = vsDramasVideoService.selectVsDramasVideoList(vsDramasVideo);
        return getDataTable(list);
    }

    /**
     * 导出短剧列表
     */
//    @ApiOperation("导出短剧列表")
    @Log(title = "短剧", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VsDramasVideo vsDramasVideo)
    {
        List<VsDramasVideo> list = vsDramasVideoService.selectVsDramasVideoList(vsDramasVideo);
        ExcelUtil<VsDramasVideo> util = new ExcelUtil<VsDramasVideo>(VsDramasVideo.class);
        util.exportExcel(response, list, "短剧数据");
    }

    /**
     * 获取短剧详细信息
     */
//    @ApiOperation("获取短剧详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(vsDramasVideoService.selectVsDramasVideoById(id));
    }

    /**
     * 新增短剧
     */
//    @ApiOperation("新增短剧")
    @Log(title = "短剧", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VsDramasVideo vsDramasVideo)
    {
        return toAjax(vsDramasVideoService.insertVsDramasVideo(vsDramasVideo));
    }

    /**
     * 修改短剧
     */
//    @ApiOperation("修改短剧")
    @Log(title = "短剧", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VsDramasVideo vsDramasVideo)
    {
        return toAjax(vsDramasVideoService.updateVsDramasVideo(vsDramasVideo));
    }

    /**
     * 删除短剧
     */
//    @ApiOperation("删除短剧")
    @Log(title = "短剧", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(vsDramasVideoService.deleteVsDramasVideoByIds(ids));
    }

    /**
     * 批量修改短剧价格
     */
//    @ApiOperation("批量修改短剧价格")
    @Log(title = "短剧", businessType = BusinessType.UPDATE)
    @PostMapping("/batchUpdateVideo")
    public void batchUpdateVideo(@RequestBody VsDramasVideo vsDramasVideo) {
        vsDramasVideoService.batchUpdateVideo(vsDramasVideo);
    }

}
